Color Math Library  0.9
Library for working with colors and color components
Functions
colormath.h File Reference
#include <propeller.h>
#include <stdlib.h>

Go to the source code of this file.

Functions

int compareRRGGBB (int c1, int c2)
 Compares two 24-bit (RRGGBB) colors and returns a value proportional to how similar they are. More...
 
int getColorRRGGBB (int r, int g, int b)
 Generates a single 24-bit (RRGGBB) color integer from individual 8-bit red, green, and blue componenets. More...
 
int get8bitColor (int c, char *i)
 Retrives the specified 8-bit (red, green, or blue) color component from a 24-bit (RRGGBB) color integer. More...
 
int remapColor (int c, char *f1, char *f2)
 Remaps a color stored as a simgle integer. More...
 

Function Documentation

int compareRRGGBB ( int  c1,
int  c2 
)

Compares two 24-bit (RRGGBB) colors and returns a value proportional to how similar they are.

Parameters
c1The first 24-bit color to be compared.
c2The second 24-bit color to be compared.
Returns
A value ranging from 0 (not similar) to 255 (the same) indicating how similar the two colors are.
int get8bitColor ( int  c,
char *  i 
)

Retrives the specified 8-bit (red, green, or blue) color component from a 24-bit (RRGGBB) color integer.

Parameters
cA 24-bit (RRGGBB) color integer.
*iA string indicating which color component should be returned: "RED", "GREEN", or "BLUE". The strings "R", "G", or "B" are acceptable.
Returns
An 8-bit value (0-255) representing the specified component of the color.
int getColorRRGGBB ( int  r,
int  g,
int  b 
)

Generates a single 24-bit (RRGGBB) color integer from individual 8-bit red, green, and blue componenets.

Parameters
rAn 8-bit value (0-255) representing the red component of a color.
gAn 8-bit value (0-255) representing the green component of a color.
bAn 8-bit value (0-255) representing the blue component of a color.
Returns
A single 24-bit (RRGGBB) color integer.
int remapColor ( int  c,
char *  f1,
char *  f2 
)

Remaps a color stored as a simgle integer.

Parameters
cThe color stored as an integer to be remapped.
*f1A string specifying the format of the color inputted. For example, a string indicating an 24-bit color integer with 8 red bits, 8 green bits, and 8 blue bits would be "8R8G8B". A 16-bit color integer with 5 red bits, 6 green bits, and 5 blue bits would be "5R6G5B".
*f2A string specifying the format of the color to be returned. The order of the color components does not have to be the same as the input order. For example, this function can be used to simply re-order the color components.
Returns
A color stored as a single integer in the specified format.